/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ToxicBakery.pagetransformer.bean;

import com.ToxicBakery.viewpager.transformer.AccordionTransformer;
import com.ToxicBakery.viewpager.view.CollPageSlide;

/**
 * 数据包装
 *
 * @since 2021-04-12
 */
public class TransformerItem {
    private final String name;
    private final Class<? extends CollPageSlide.PageTransformer> clz;

    /**
     * 创建 TransformerItem
     *
     * @param clz 动画类型
     */
    public TransformerItem(Class clz) {
        this.name = clz.getSimpleName();
        this.clz = clz;
    }

    /**
     * 获取动画名字
     *
     * @return 动画名字
     */
    public String getName() {
        return name;
    }

    /**
     * 获取动画类型
     *
     * @return 返回动画类型
     */
    public CollPageSlide.PageTransformer getPageTransformer() {
        try {
            return clz.newInstance();
        } catch (IllegalAccessException | InstantiationException e) {
            return new AccordionTransformer();
        }
    }
}
